<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <title>系统日志</title>
    <%@ include file="/WEB-INF/views/modules/commons/head.jsp" %>
    <%--多选css--%>
    <link rel="stylesheet" href="<s:url value="/assets/web/js/multiSelect/css/fselect.css"></s:url>">
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
    <style>
        #gridTable tr td {
            text-align: center;
        }

        #gview_gridTable thead tr th .ui-jqgrid-sortable {
            text-align: center;
        }

        /*转成省略号*/
        /*.ui-jqgrid tr.jqgrow td { text-overflow : ellipsis; }*/
        .ui-jqgrid tr.jqgrow td {
            white-space: normal !important;
            height: 25px;
            line-height: 25px;
            vertical-align: text-top;

        }

        .nav {
            margin-left: 0;
        }

        #gview_gridTable .ui-jqgrid-bdiv {
            max-height: 450px;
        !important;
        }

        .nav > li > a:focus, .nav > li > a:hover {
            text-decoration: none;
            background-color: #33CCFF !important;
        }

        #main-container {
            padding-top: 45px;
            position: relative;
            height: calc(100%);
            margin-left: 17.5%;
            margin-top: 60px;
        }

        .modal-dialog {
            z-index: 9999999;
        }

        @media (min-width: 768px) {
            .modal-content {
                -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, .5);
                box-shadow: 0 -2px 20px rgba(0, 0, 0, .5) !important;
            }
        }

        td {
            cursor: default;
        }

        /*个数*/
        #banjieNum {
            background-color: #d15b47 !important;
            margin: 10px 3px;
            color: #fff;
            position: absolute;
            top: -15px;
            right: -17px;
        }

        .project_detail_css {
            position: absolute;
            top: -36px;
            right: 20px;
            border: 1px solid #aaa;
            padding: 1px 5px;
        }

        .pdd {
            margin: 5px 0px;
        }

        .ppdd {
            margin: 0px;
        }
    </style>
</head>
<body class="bgcolor">
<%@ include file="/WEB-INF/views/modules/commons/nav.jsp" %>
<%@ include file="/WEB-INF/views/modules/commons/menu.jsp" %>
<!-- /section:basics/navbar.layout -->
<table></table>
<div class="main-container" id="main-container">
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <script type="text/javascript">
            try {
                ace.settings.check('main-container', 'fixed')
            } catch (e) {
            }
        </script>

        <!-- /section:basics/sidebar -->
        <div class="main-content">
            <div class="main-content-inner">
                <div class="page-content">
                    <!-- /section:settings.box -->
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="pull-right">
                                <shiro:hasPermission name="modules:sys:log:query">
                                    <button class="btn btn-sm btn-info" id="query">查询</button>
                                </shiro:hasPermission>

                                <shiro:hasPermission name="modules:sys:log:excel">
                                    <button class="btn btn-sm btn-pink" id="export">导出</button>
                                </shiro:hasPermission>

                                <shiro:hasPermission name="modules:sys:log:query">
                                    <button class="btn btn-sm btn-info" id="chart">报表</button>
                                </shiro:hasPermission>

                                <shiro:hasPermission name="modules:sys:log:query">
                                    <button class="btn btn-sm btn-info" id="print">打印</button>
                                </shiro:hasPermission>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-xs-12">
                            <!-- PAGE CONTENT BEGINS -->
                            <!-- jqGrid表格 -->
                            <table id="gridTable"></table>
                            <!-- jqGrid工具类 -->
                            <div id="gridPager"></div>
                            <!-- 查询对话框 -->
                            <div style="display: none;">
                                <div class="row" id="queryDialog"></div>
                            </div>
                            <!-- PAGE CONTENT ENDS -->
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                </div><!-- /.page-content -->
            </div>
        </div><!-- /.main-content -->

        <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
            <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
        </a>

        <!-- dialog -->
        <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
    </div><!-- /.main-content -->
</div><!-- /.main-container -->
<!-- footer -->
<script src="<s:url value="/assets/web/js/jquery.min.js?v=2.1.4"></s:url>"></script>
<%--公用js--%>
<script src="<s:url value="/assets/web/js/commo.js"></s:url>"></script>
<link rel="stylesheet" href="<s:url value="/assets/web/css/login/bootstrap.min.css?v=3.3.6"></s:url>">
<script src="<s:url value="/assets/web/js/jqpaginator.min.js"></s:url>"></script>
<script src="<s:url value="/assets/web/js/baseAPI.js"></s:url>"></script>
<%--多选js--%>
<script src="<s:url value="/assets/web/js/multiSelect/js/fselect.js"></s:url>"></script>
<script src="<s:url value="/assets/web/common/bootstrapvalidator/dist/js/bootstrapValidator.js"></s:url>"></script>
<%@ include file="/WEB-INF/views/include/footer.jsp" %>
<!-- dialog -->
<%@ include file="/WEB-INF/views/include/dialog.jsp" %>

<script type="text/javascript">
    //基本路径
    var baseUrl = "<s:url value="/modules/sys/log"></s:url>/"

    //jqgrid的表格高度
    var height = 320;
    //jqgrid表格行头的中文
    var colNames = ['日期','日志类型', 'IP地址', '操作的URI', '操作的方式', '提交的数据', '代理信息', '异常信息'];
    //jqgrid表格中每一行的信息模型
    var colModel = [
        {name:'createDate',index:'createDate', width:40, editable: true},
        {name:'type',index:'type', width:40, editable: true, formatter: logTypeFmatter},
        {name:'remoteAddr',index:'remoteAddr', width:40, editable: true},
        {name:'requestUri',index:'requestUri', width:100, editable: true},
        {name:'method',index:'method', width:40, editable: true},
        {name:'params',index:'params', width:40, editable: true},
        {name:'userAgent',index:'userAgent', width:100, editable: true},
        {name:'exception',index:'exception', width:40, editable: true}
    ];

    //jqgrid的具体执行方法
    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager"
    });

    //加载查询对话框
    $("#queryDialog").load(getUrl("filter"));

    //重置表单
    function reset() {
        resetForm("#formDialog form");
    }

    //显示查询对话框
    var queryDialog = $("#queryDialog");
    $("#query").click(function () {
        showDialog({
            dialogTitle: '查询对话框',
            dialogBody: queryDialog,
            dialogFoot: "<button type='button' class='btn btn-primary' onclick='query()'>查询</button>" +
                "<button type='button' class='btn btn-pink' onclick='reset()'>重置</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
        });
    });
    function logTypeFmatter(cellvalue, options, rowObject) {
        if (cellvalue == "1") {
            return "接入日志";
        }  else {
            return "错误日志";
        }
    }
    //具体查询方法
    function query() {
        seachJqgird("#gridTable", "#formDialog form");
        $("#formDialog").modal('hide');
    }

    $("#chart").click(function () {
        var url = '<s:url value="/modules/sys/log/chart"></s:url>';
        window.parent.openapp(url, 'sysLogChart', '日志报表');
    });

    $("#print").click(function () {
        showDialog({
            dialogTitle: '打印预览',
            dialogBody: $("#gridTable").html(),
            dialogFoot: "<button type='button' class='btn btn-pink' onclick='print()'>打印</button>" +
                "<button type='button' class='btn btn-default' data-dismiss='modal'>关闭</button>"
        });
    });

    function print() {
        $("#gridTable").printFinal({
            preview: false,//打印预览
            impcss: true//引入css文件
        });
    }
</script>
</body>

</html>